'''
Created on 27/03/2011

@author: bruno
'''
from MP3file import MP3file
from DatabaseClasses import Music
import Repositories


mp3filetest = MP3file("/home/bruno/Desktop/python/katy_perry_aqua_i_kissed_a_barbie_girl.mp3")

music = Music(musicFile=mp3filetest)

repositorio = Repositories.Repository()

print '----------------------------------------'
print'lista todas as musicas'
print repositorio.getAll(Music)

print '\n----------------------------------------'
print'adiciona musica a sessao'

repositorio.add(music)

print '\n----------------------------------------'
print'lista todas as musicas - SEM COMMIT'
print repositorio.getAll(Music)

print '\n----------------------------------------'
print'efetua o commit'
repositorio.persist()

print '\n----------------------------------------'
print'lista todas as musicas - APOS COMMIT'
print repositorio.getAll(Music)

print '\n----------------------------------------'
print'obtem por id'
print repositorio.get(Music,music.id)

print '\n----------------------------------------'
print'obter por atributo'
print repositorio.get_by(Music, 'artist', 'KenCarson')
